package 力扣日常刷题.木22二月.第06天212;

import java.util.Arrays;

/**
 * @author 帅小伙
 * @date 2022/2/12
 * @description
 */
public class Demo49贪心分饼干 {

    // g需求   s饼干大小
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int ans = 0;
        for (int i = 0, j  = 0; i < g.length && j < s.length; i++,j++) {
            while(j < s.length && g[i] > s[j]){
                j++;
            }
            if(j < s.length) ans++;
        }
        return ans;
    }
}
